﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class my_add_article : System.Web.UI.Page
{
    int no;
    int cno;
    
    protected void Page_Load(object sender, EventArgs e)
    {
       
        no = int.Parse(Request["no"]);
        cno = int.Parse(Request["cno"]);

        String backurl = "add_article.aspx?no=" + no + "&cno=" + cno;

        ctp_lib.check_login(this.Page, backurl);

        if (!this.IsPostBack)
        {
            ctpDataContext db = new ctpDataContext();
            var data = from p in db.ct_s_profiles
                       where p.ct_no == cno && p.valid == true
                       select p.title;

            this.DropDownList1.DataSource = data;
            this.DataBind();
        }

    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        
        
        ctpDataContext db = new ctpDataContext();
        ct_s_profile cts = db.ct_s_profiles.Single(p => p.valid == true && p.title == DropDownList1.SelectedItem.Value.ToString());

        ct_s_intro i = new ct_s_intro();
        i.create_user_no = no;
        i.ct_s_no = cts.no;
        i.ct_no = cts.ct_no;
        i.intro = this.TextBox1.Text;
        i.language_no = (int)Session["now_user_lang_no"];

        db.ct_s_intros.InsertOnSubmit(i);
        db.SubmitChanges();
        
        this.Label3.Text = cts.no.ToString();
    }
}
